It looks like Raustats might not be what I am looking for to get SLA level census data quickly. Let’s try Census2016 from Hugh Parsonage.
rr full_2016_census <- Census2016_wide_by_SA2_year %>% filter(year == ‘2016’ ) head(full_2016_census)
Yes - this is what I need.
Loading other tables
rr ancestories_2016 <- Census2016_ancestories %>% filter(year == ‘2016’ ) countries_of_birth_2016 <- Census2016_countries_of_birth %>% filter(year == ‘2016’ ) languages_2016 <- Census2016_languages %>% filter(year == ‘2016’ ) religions_2016 <- Census2016_religions %>% filter(year == ‘2016’ )
Each of the four variables ancestory, country of birth, languages and religions are quite granular, and it may make sense to look at these variables at a lower level of granularity.
Ancestory:
rr download.file(‘https://www.abs.gov.au/AUSSTATS/subscriber.nsf/log?openagent&12490do0001_201912.xls&1249.0&Data%20Cubes&674EFC4CA0A3D8FDCA2584D30012B905&0&2019&18.12.2019&Latest’, ‘./Data/ancestry_classification.xls’, method = ‘libcurl’)
ancestry_classification_4dig <- readxl::read_xls(‘./Data/ancestry_classification.xls’, sheet = ‘Table 1.3’, skip = 7, col_names = c(‘X1’, ‘X2’, ‘Ancestory_Code_4’, ‘Ancestory’)) %>% filter(!is.na(Ancestory)) %>% select(Ancestory_Code_4, Ancestory)
ancestry_classification_1dig <- readxl::read_xls(‘./Data/ancestry_classification.xls’, sheet = ‘Table 1.1’, skip = 5, col_names = c(‘Ancestory_Code_1’, ‘Ancestory_Group’))%>% filter(!is.na(Ancestory_Group))
Country of birth
rr download.file(‘https://www.abs.gov.au/ausstats/subscriber.nsf/log?openagent&sacc_12690do0001_201903.xls&1269.0&Data%20Cubes&480BD730AF42D515CA2583BD007707C5&0&2016&15.03.2019&Latest’, ‘./Data/country_classification.xls’, method = ‘libcurl’)
country_classification_4dig <- readxl::read_xls(‘./Data/country_classification.xls’, sheet = ‘Table 1.3’, skip = 7, col_names = c(‘X1’, ‘X2’, ‘Country_Code_4’, ‘Country’)) %>% filter(!is.na(Country)) %>% select(-X1, -X2)
country_classification_2dig <- readxl::read_xls(‘./Data/country_classification.xls’, sheet = ‘Table 1.2’, skip = 6, col_names = c(‘X1’, ‘Country_Code_2’, ‘Country_Name_2’)) %>% filter(!is.na(Country_Name_2)) %>% select(-X1)
country_classification_1dig <- readxl::read_xls(‘./Data/country_classification.xls’, sheet = ‘Table 1.1’, skip = 5, col_names = c(‘Country_Code_1’, ‘Country_Group’)) %>% filter(!is.na(Country_Group))
Language
rr download.file(‘https://www.abs.gov.au/AUSSTATS/subscriber.nsf/log?openagent&ASCL_12670DO0001_201703.xls&1267.0&Data%20Cubes&F84620CF6E13F7E8CA257FF1001E68A7&0&2016&28.03.2017&Latest’, ‘./Data/language_classification.xls’, method = ‘libcurl’)
language_classification_4dig <- readxl::read_xls(‘./Data/language_classification.xls’, sheet = ‘Table 1.3’, skip = 8, col_names = c(‘X1’, ‘X2’, ‘X3’, ‘X4’, ‘Language_Code_3’, ‘Language’)) %>% filter(!is.na(Language)) %>% select(-X1, -X2, -X3, -X4)
language_classification_1dig <- readxl::read_xls(‘./Data/language_classification.xls’, sheet = ‘Table 1.1’, skip = 5, col_names = c(‘Language_Code_1’, ‘Language_Group’)) %>% filter(!is.na(Language_Group))
Religion
rr download.file(‘https://www.abs.gov.au/AUSSTATS/subscriber.nsf/log?openagent&ASCRG_12660DO0001_201707.xls&1266.0&Data%20Cubes&B3EAFE3FE6180D37CA257FF1001E673C&0&2016&14.07.2017&Latest’, ‘./Data/religion_classification.xls’, method = ‘libcurl’)
religion_classification_3dig <- readxl::read_xls(‘./Data/religion_classification.xls’, sheet = ‘Table 1.2’, skip = 6, col_names = c(‘X1’, ‘Religion_Code_3’, ‘Religion’)) %>% filter(!is.na(Religion)) %>% select(-X1)
religion_classification_1dig <- readxl::read_xls(‘./Data/religion_classification.xls’, sheet = ‘Table 1.1’, skip = 5, col_names = c(‘Religion_Code_1’, ‘Religion_Group’)) %>% filter(!is.na(Religion_Group))
Aggregate at the SA2 level - add unless variable contains median, average, persons_per_bedroom
census_2016_all_vars <- Census2016_wide_by_SA2_year %>%
filter(year == '2016') %>%
rowwise() %>%
mutate(sa2_id = paste0(substr(sa2_code, 1, 1), substr(sa2_code, 6, 9))) %>%
filter(isMissing == FALSE) %>%
mutate(percent_female = female/persons,
percent_defacto = defacto_persons/persons,
percent_married = married_persons/persons,
percent_indig = indig_persons/persons,
percent_born_in_australia = born_in_australia/persons,
percent_unit = flat_or_unit/n_dwellings,
percent_mortgage = dwelling_owned_mortgage/n_dwellings,
percent_rent = dwelling_rented/n_dwellings)
census_2016_means <- census_2016_all_vars %>%
select(median_age, median_household_income, average_household_size,
persons_per_bedroom, median_weekly_rent, median_annual_mortgage, sa2_id) %>%
group_by(sa2_id) %>%
summarise_all(mean, na.rm = TRUE)
census_2016_counts <- census_2016_all_vars %>%
select(n_dwellings, persons, female, male,
married_persons, married_females, married_males, defacto_persons,
defacto_females, defacto_males, notmarried_persons,
notmarried_females, notmarried_males, indig_persons,
indig_males, indig_females, non_indig_persons,
non_indig_females, non_indig_males, not_stated_indig_persons,
not_stated_indig_males, not_stated_indig_females,
born_in_australia, born_overseas, country_not_stated,
separate_house, flat_or_unit, housing_other_or_not_stated, semi_or_townhouse,
dwelling_owned_outright, dwelling_owned_mortgage, dwelling_other_or_not_stated,
dwelling_rented, sa2_id) %>%
group_by(sa2_id) %>%
summarise_all(sum, na.rm = TRUE) %>%
mutate(percent_female = female/persons,
percent_defacto = defacto_persons/persons,
percent_married = married_persons/persons,
percent_indig = indig_persons/persons,
percent_born_in_australia = born_in_australia/persons,
percent_unit = flat_or_unit/n_dwellings,
percent_mortgage = dwelling_owned_mortgage/n_dwellings,
percent_rent = dwelling_rented/n_dwellings)
So what I need is weighted demographic data for each of the polling places based on the number of people from each SLA2 who voted at the polling place. Since we don’t know who voted where, and who can vote at all, we are making the naive assumptions that * Voters at each SLA are similar * Voters are representitive of census respondents at the SLA2 level.
Download and load polling places by SA1
download.file('https://www.aec.gov.au/Elections/Federal_Elections/2016/files/polling-place-by-sa1s-2016.xlsx', './Data/polling-place-by-sa1s-2016.xlsx', method = 'libcurl')
trying URL 'https://www.aec.gov.au/Elections/Federal_Elections/2016/files/polling-place-by-sa1s-2016.xlsx'
Content type 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' length 31087463 bytes (29.6 MB)
==================================================
downloaded 29.6 MB
polling_place_data <- readxl::read_xlsx('./Data/polling-place-by-sa1s-2016.xlsx')
Aggregate polling place data to SA2
rr polling_place_sa2 <- polling_place_data %>% mutate(sa2_id = floor(SA1_id / 100)) %>% group_by(year, state_ab, div_nm, pp_id, pp_nm, sa2_id) %>% summarise(votes = sum(votes))
Combine with demographic data and aggregate
polling_place_demog <- polling_place_sa2 %>%
mutate(sa2_id = as.character(sa2_id)) %>%
inner_join(census_2016_all_vars)
polling_place_demog_means <- polling_place_demog %>%
select(year, state_ab, div_nm, pp_id, pp_nm, sa2_id, votes,
median_age, median_household_income, average_household_size,
persons_per_bedroom, median_weekly_rent, median_annual_mortgage,
percent_female, percent_defacto, percent_married, percent_indig,
percent_born_in_australia, percent_unit, percent_mortgage, percent_rent) %>%
group_by(year, state_ab, div_nm, pp_id, pp_nm) %>%
summarise_at(vars(median_age, median_household_income,
average_household_size, persons_per_bedroom, median_weekly_rent,
median_annual_mortgage, percent_female, percent_defacto,
percent_married, percent_indig, percent_born_in_australia,
percent_unit, percent_mortgage,
percent_rent), funs(weighted.mean(., w=votes)))
Add in 2pp at the polling booth level
rr election_2pp <- twoparty_pollingbooth_download()
trying URL 'https://github.com/ropenscilabs/eechidna/raw/master/extra-data/tpp_pp.rda'
Content type 'application/octet-stream' length 1677810 bytes (1.6 MB)
==================================================
downloaded 1.6 MB
rr polling_place_2pp <- polling_place_demog_means %>% group_by() %>% rename(StateAb = state_ab, DivisionNm = div_nm, PollingPlace = pp_nm) %>% mutate(DivisionNm = toupper(DivisionNm), PollingPlace = toupper(PollingPlace)) %>% left_join(election_2pp %>% filter(year == 2016))
Joining, by = c(\year\, \StateAb\, \DivisionNm\, \PollingPlace\)
Check for missing data
polling_place_2pp %>%
summarise_all(funs(sum(is.na(.))))
Which booths are null?
polling_place_2pp %>%
filter(is.na(TotalVotes)) %>%
tabyl(PollingPlace)
PollingPlace n percent
ABSENT 150 0.25
POSTAL 150 0.25
PRE-POLL 150 0.25
PROVISIONAL 150 0.25
So the Absent, Postals, Pre-Poll and Provisional votes aren’t in this table. Let’s come back to those…
polling_place_2pp %>%
summarise_all(funs(sum(is.null(.))))
Remove the rows with NAs
polling_place_2pp_clean <- polling_place_2pp %>%
filter(!is.na(TotalVotes))
polling_place_2pp_clean %>%
summarise_all(funs(sum(is.na(.))))
Which polling stations have missing data? Not too concerned about post code, as there are some special booths
polling_place_2pp_clean %>%
filter(is.na(median_age)|is.na(Latitude))
Looks like mobile teams and prepoll centres, and only latitude and longitude. Will remove the Brand mobile team, as the demographic data does not look valid.
polling_place_2pp_clean<- polling_place_2pp_clean %>%
dplyr::filter(PollingPlaceID != 65161)
polling_place_2pp_clean %>%
ggplot(aes(x = LNP_Percent/100)) + stat_density(geom="line", colour = 'blue') +
theme_classic(base_size = 16) +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: LNP 2 Party Preferred Percentage', x = '2PP Percentage',
y = 'Density', subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
ggplot(aes(x = ALP_Percent/100)) + stat_density(geom="line", colour = 'red') +
theme_classic(base_size = 16) +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', x = '2PP Percentage',
y = 'Density', subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
ggplot(aes(x = Swing/100)) + stat_density(geom="line", colour = 'purple') +
theme_classic(base_size = 16) +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: Swing to Incumbent', x = 'Swing',
y = 'Density', subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
ggplot(aes(x = median_household_income)) + stat_density(geom="line", colour = 'purple') +
theme_classic(base_size = 16) +
scale_x_continuous(labels=scales::dollar) +
labs(title = '2016 Census: Median Income', x = 'Median Income',
y = 'Density', subtitle = 'by Polling Booth, Unweighted')
Can we look at these distributions by state?
polling_place_2pp_clean %>%
ggplot(aes(x = ALP_Percent/100, colour = StateAb)) +
stat_density(geom="line", position = 'dodge') +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', x = '2PP Percentage',
y = 'Frequency', subtitle = 'by Polling Booth, Unweighted')
What about by median income
polling_place_2pp_clean %>%
ggplot(aes(y = ALP_Percent/100, x = median_household_income, colour = StateAb)) +
geom_point() +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::dollar) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', x = 'Booth Median Income',
y = 'ALP 2pp Percentage', subtitle = 'by Polling Booth, Unweighted') +
facet_wrap(~StateAb, nrow = 4)
What about comparing NSW electorates? There seems to be an odd separation in income bands for low ALP 2pp. Could this be a regional vs city difference?
fp_booth_16 <- firstpref_pollingbooth_download() %>%
filter(year == 2016)
trying URL 'https://github.com/ropenscilabs/eechidna/raw/master/extra-data/fp_pp.rda'
Content type 'application/octet-stream' length 3227934 bytes (3.1 MB)
==================================================
downloaded 3.1 MB
polling_2cp <- read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseTcpByCandidateByPollingPlaceDownload-20499.csv', skip = 1)
polling_2pp <- read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseTppByPollingPlaceDownload-20499.csv', skip = 1)
fp_booth_2016 <- read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-20499-NSW.csv', skip = 1) %>%
rbind(read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-20499-VIC.csv', skip = 1)) %>%
rbind(read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-20499-QLD.csv', skip = 1)) %>%
rbind(read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-20499-SA.csv', skip = 1)) %>%
rbind(read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-20499-WA.csv', skip = 1)) %>%
rbind(read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-20499-TAS.csv', skip = 1)) %>%
rbind(read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-20499-NT.csv', skip = 1)) %>%
rbind(read_csv('https://results.aec.gov.au/20499/Website/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-20499-ACT.csv', skip = 1))
coalition_contest_2016 <- fp_booth_2016 %>%
group_by(DivisionNm, PartyNm, HistoricElected) %>%
summarise(OrdinaryVotes = sum(OrdinaryVotes)) %>%
filter(PartyNm %in% c('Liberal', 'Country Liberals (NT)',
'Liberal National Party of Queensland',
'The Nationals')) %>%
group_by(DivisionNm) %>%
top_n(1) %>%
select(DivisionNm, PartyNm)
Selecting by OrdinaryVotes
If we look at a couple of the states where high income booths tend to vote strongly for the coalition as well as lower income booths, we can see that some (but not all) of the lower income booths are contested by The Nationals. This indicares (not surprisingly) that Nationals voters and Liberal voters are different socio-economically, or possibly that city and country coalition voters differ.
polling_place_2pp_clean %>%
mutate(DivisionNm = stringr::str_to_title(DivisionNm)) %>%
inner_join(coalition_contest_2016) %>%
filter(StateAb == 'NSW') %>%
ggplot(aes(y = ALP_Percent/100, x = median_household_income, colour = PartyNm)) +
geom_point(size = 3) +
theme_classic(base_size = 16) + scale_color_manual(values = c('blue', 'dark green')) +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::dollar) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', x = 'Booth Median Income',
y = 'ALP 2pp Percentage', colour = 'Coalition Party',
subtitle = 'by Polling Booth, Unweighted (NSW)')
polling_place_2pp_clean %>%
mutate(DivisionNm = stringr::str_to_title(DivisionNm)) %>%
inner_join(coalition_contest_2016) %>%
filter(StateAb == 'VIC') %>%
ggplot(aes(y = ALP_Percent/100, x = median_household_income, colour = PartyNm)) +
geom_point(size = 3) +
theme_classic(base_size = 16) + scale_color_manual(values = c('blue', 'dark green')) +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::dollar) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', x = 'Booth Median Income',
y = 'ALP 2pp Percentage', colour = 'Coalition Party',
subtitle = 'by Polling Booth, Unweighted (VIC)')
This effect is less clear in states where the Nationals aren’t as prominent, either because the Nationals aren’t as prominent (SA, WA, TAS), or are merged with the Liberals (QLD).
polling_place_2pp_clean %>%
mutate(DivisionNm = stringr::str_to_title(DivisionNm)) %>%
inner_join(coalition_contest_2016) %>%
filter(StateAb == 'WA') %>%
ggplot(aes(y = ALP_Percent/100, x = median_household_income, colour = PartyNm)) +
geom_point(size = 3) +
theme_classic(base_size = 16) + scale_color_manual(values = c('blue', 'dark green')) +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::dollar) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', x = 'Booth Median Income',
y = 'ALP 2pp Percentage', colour = 'Coalition Party',
subtitle = 'by Polling Booth, Unweighted (WA)')
Perhaps we would be better off using the geographical classifications from the AEC.
library(rvest)
webpage <- read_html("http://results.aec.gov.au/20499/Website/HouseDivisionClassifications-20499-NAT.htm")
Division_Classifications <- webpage %>%
html_nodes("#divisionClassifications") %>%
html_table(fill = TRUE) %>%
.[[1]]
Division_Classifications <- Division_Classifications %>%
filter(Division != 'Total Enrolment')
The graph below shows that the booths that have a low ALP 2pp and a low median income are primarily rural booths. This relationship seems stronger than the Lib/Nat split.
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
filter(StateAb == 'NSW') %>%
ggplot(aes(y = ALP_Percent/100, x = median_household_income, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::dollar) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage',
y = 'ALP 2pp Percentage',
x = 'Booth Median Income', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted (NSW)')
Looking at all states we see a similar relationship, although less strong than in NSW.
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = median_household_income, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::dollar) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Median Booth Income', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')
What about some of the other variables?
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = average_household_size, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Average Household Size', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = percent_female, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_x_continuous(labels=scales::percent) +
scale_y_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Percent Female', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
select(ALP_Percent, Swing, median_age, median_household_income, average_household_size,
persons_per_bedroom, median_weekly_rent, median_annual_mortgage,
percent_female, percent_defacto, percent_born_in_australia,
percent_unit, percent_mortgage, percent_rent) %>%
cor %>%
kable()
| ALP_Percent | Swing | median_age | median_household_income | average_household_size | persons_per_bedroom | median_weekly_rent | median_annual_mortgage | percent_female | percent_defacto | percent_born_in_australia | percent_unit | percent_mortgage | percent_rent | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ALP_Percent | 1.0000000 | -0.2924398 | -0.4148188 | 0.0049899 | 0.1785014 | 0.3698085 | 0.1675435 | 0.1230552 | 0.1245266 | 0.1270139 | -0.3301750 | NA | NA | NA |
| Swing | -0.2924398 | 1.0000000 | 0.0592447 | 0.1044271 | -0.0872137 | 0.0165807 | 0.0817794 | 0.0964162 | 0.0734776 | 0.0042180 | -0.0448560 | NA | NA | NA |
| median_age | -0.4148188 | 0.0592447 | 1.0000000 | -0.4804955 | -0.5175758 | -0.5943939 | -0.4116337 | -0.4221270 | -0.0574141 | -0.0502159 | 0.5197535 | NA | NA | NA |
| median_household_income | 0.0049899 | 0.1044271 | -0.4804955 | 1.0000000 | 0.4183950 | 0.3362658 | 0.8029106 | 0.8644605 | 0.1982974 | -0.0693950 | -0.3959055 | NA | NA | NA |
| average_household_size | 0.1785014 | -0.0872137 | -0.5175758 | 0.4183950 | 1.0000000 | 0.3887206 | 0.3408666 | 0.3284517 | -0.0032833 | -0.5164718 | -0.3020229 | NA | NA | NA |
| persons_per_bedroom | 0.3698085 | 0.0165807 | -0.5943939 | 0.3362658 | 0.3887206 | 1.0000000 | 0.4120754 | 0.4015767 | 0.0035249 | 0.0094906 | -0.5938012 | NA | NA | NA |
| median_weekly_rent | 0.1675435 | 0.0817794 | -0.4116337 | 0.8029106 | 0.3408666 | 0.4120754 | 1.0000000 | 0.9276979 | 0.4307971 | -0.1337758 | -0.6013994 | NA | NA | NA |
| median_annual_mortgage | 0.1230552 | 0.0964162 | -0.4221270 | 0.8644605 | 0.3284517 | 0.4015767 | 0.9276979 | 1.0000000 | 0.3628219 | -0.1183373 | -0.5499270 | NA | NA | NA |
| percent_female | 0.1245266 | 0.0734776 | -0.0574141 | 0.1982974 | -0.0032833 | 0.0035249 | 0.4307971 | 0.3628219 | 1.0000000 | -0.1010107 | -0.1145354 | NA | NA | NA |
| percent_defacto | 0.1270139 | 0.0042180 | -0.0502159 | -0.0693950 | -0.5164718 | 0.0094906 | -0.1337758 | -0.1183373 | -0.1010107 | 1.0000000 | 0.2383005 | NA | NA | NA |
| percent_born_in_australia | -0.3301750 | -0.0448560 | 0.5197535 | -0.3959055 | -0.3020229 | -0.5938012 | -0.6013994 | -0.5499270 | -0.1145354 | 0.2383005 | 1.0000000 | NA | NA | NA |
| percent_unit | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 1 | NA | NA |
| percent_mortgage | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 1 | NA |
| percent_rent | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 1 |
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = persons_per_bedroom, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Persons per Bedroom', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = percent_unit, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Percent of Dwellings - Unit', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = percent_mortgage, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Percent of Dwellings - Under Mortgage', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = percent_rent, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Percent of Dwellings - Renting', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = percent_indig, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Percent Indigeneous', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = percent_born_in_australia, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Percent Born in Australia', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')
polling_place_2pp_clean %>%
mutate(Division = stringr::str_to_title(DivisionNm)) %>%
inner_join(Division_Classifications) %>%
ggplot(aes(y = ALP_Percent/100, x = percent_defacto, colour = Demographic)) +
geom_point(size = 1) +
theme_classic(base_size = 16) + scale_color_brewer(palette = "Dark2") +
theme(legend.position = 'bottom') +
scale_y_continuous(labels=scales::percent) +
scale_x_continuous(labels=scales::percent) +
labs(title = '2016 Election: ALP 2 Party Preferred Percentage', y = 'ALP 2pp Percentage',
x = 'Percent in a Defacto Relationship', colour = 'Region',
subtitle = 'by Polling Booth, Unweighted')